class Solution:
    def permute(self, nums: List[int]) -> List[List[int]]:
        res = []
        def backtrack(path=[], selects=nums):
            if not selects:
                res.append(path[:])
                return
            for i in range(len(selects)):
                path.append(selects[i])
                backtrack(path, selects[:i] + selects[i+1:])
                path.pop()
        backtrack()
        return res